package com.zx.webflux.eunms;

import lombok.Getter;

/**
 * @program: common
 * @description: 错误信息包装枚举
 * @author: zhou  xun
 * @create: 2022-09-26 23:54
 */
@Getter
public enum WrapperErrEum {
    /**
     * 错误枚举
     */
    SUCCESS(1, "成功"),
    FAIL(-1, "失败"),
    UNKNOWN_ERROR(-2, "未知错误");

    /**
     * 返回码
     */
    private final Integer code;
    /**
     * 返回信息
     */
    private final String msg;

    WrapperErrEum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static WrapperErrEum getErrEnumByCode(Integer code) {
        for (WrapperErrEum wrapperErrEum : values()) {
            if (wrapperErrEum.code.equals(code)) {
                return wrapperErrEum;
            }
        }
        return null;
    }

}
